package com.zyx.yygh.oss.controller;

import com.zyx.yygh.common.result.Result;
import com.zyx.yygh.oss.service.FileService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * @author zyx
 * @version 1.0
 * @date 2022/1/22 022 19:06
 */
@RestController
@RequestMapping("/api/oss/file")
public class FileApiController {

    @Resource
    private FileService fileService;
    /**
     * 上传文件到阿里云oss
     */
    @PostMapping("fileUpload")
    public Result fileUpload(MultipartFile file){

        String url = fileService.upload(file);
        return Result.ok(url);
    }
}
